<?php
namespace app\common\model;
use AlibabaCloud\DBFS\V20200418\DbfsRecord;
use PhpOffice\PhpSpreadsheet\IOFactory;
use think\facade\Env;
use think\Model as ThinkModel;
use think\Db;

//会员资金变动模型
class ViperMoneyLog extends ThinkModel
{
    // 设置当前模型对应的完整数据表名称
    protected $table = '__QT_VIPER_MONEY_LOG__';
    protected $name = 'qt_viper_money_log';
    protected $pk = 'id';
    protected $autoWriteTimestamp = true;


    /**
     * 会员资金变动记录
     * @param $viperCardId [会员卡ID]
     * @param $orderId [关联订单ID]
     * @param $type [变更类型 1 充值 2 转账 3 消费]
     * @param $money [变更金额]
     * @param $check [变更类型 1：增加 2：减少]
     * @param $flag [资金类型 1=账户余额 2=积分 3 赠送金额]
     * @param $afterMoney [变更后金额]
     * @param string $content [备注]
     */
    public static function moneyLog($viperCardId,$orderId,$type,$money,$check,$flag,$afterMoney,$content = ''){
        $insertLog = [
            'viper_card_id'=>$viperCardId,
            'order_id'=>$orderId,
            'type'=>$type,
            'money'=>$money,
            'check'=>$check,
            'flag'=>$flag,
            'after_money'=>$afterMoney,
            'content'=>$content,
            'create_time'=>time()
        ];
        self::create($insertLog);
    }
}